//
//  BaseView.m
//  YiCuiMiaoZhang
//
//  Created by Sings on 2019/3/28.
//  Copyright © 2018 益萃网络科技（中国）有限公司. All rights reserved.
//

#import "BaseView.h"
#import "BaseBlock.h"

@implementation BaseView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype) initWithViewModel:(BaseViewModel *) viewModel {
    if (self = [super init]) {
        [self initView];
        self.viewModel = viewModel;
    }
    return self;
}

- (void) initView {
    
}


- (void)setViewModel:(BaseViewModel *)viewModel {
    if (_viewModel) {
        _viewModel.refresh = nil;
    }
    _viewModel = viewModel;
    BaseWeakObj(self)
    _viewModel.refresh = ^{
        [weakself refreshView];
        
    };
    [self showView];
}

- (void)showView {
}

- (void)refreshView {
    [self showView];
}

@end
